<!-- 隐藏导航条 -->
<div id="sideNav" href="#">
    <i class="fa fa-caret-right"></i>
</div>
<div class="sidebar-collapse">
    <!-- 具体条目 ..-->
    <div class="sidebar-collapse">
        <ul class="nav" id="main-menu">
            <li id="yuan"><a href="#"><i class="fa fa-sitemap"></i> 元数据<span
                    class="fa arrow"></span></a>
                <ul class="nav nav-second-level">
                    <li><a id="meta_sensor" href="#"><i class="fa fa-edit"></i>设备基本信息</a>
                    </li>
                    <!--
                 <li><a id="meta_water" href="#"><i class="fa fa-table"></i>水信息</a>
                    </li> -->
                    <li><a id="shuipingheng" href="#"><i class="fa fa-qrcode"></i>水平衡测试<span
                            class="fa arrow"></span></a>
                        <ul class="nav nav-third-level">

                            <li><a id="meta_eva_wsrc_info" href="#"><i
                                    class="fa fa-bar-chart-o"></i>企业取水水源情况</a></li>

                            <li><a id="meta_eva_year_wuse_info" href="#"><i
                                    class="fa fa-bar-chart-o"></i>企业年用水情况</a></li>
                            <li><a id="meta_eva_unit_wbal_test" href="#"><i
                                    class="fa fa-bar-chart-o"></i>用水单元水平衡测试</a></li>
                            <li><a id="meta_eva_wbal_test" href="#"><i
                                    class="fa fa-bar-chart-o"></i>企业水平衡测试统计表</a></li>

                        </ul>
                    </li>
                    <!--                    <li><a id="meta_waste_water" href="#"><i class="fa fa-bar-chart-o"></i>废水排放评估</a>-->
                    <!--                    <li><a id="meta_discharge" href="#"><i class="fa fa-bar-chart-o"></i>废水排放评估(new)</a>-->
                    <li><a id="meta_discharge" href="#"><i class="fa fa-bar-chart-o"></i>废水排放评价</a>
                    <li><a id="meta_standard" href="#"><i class="fa fa-edit"></i>节水型企业评价</a></li>
                    <li><a id="meta_QSDE" href="#"><i class="fa fa-edit"></i>取水定额评估</a></li>
                    <li><a id="meta_clean_product" href="#"><i class="fa fa-bar-chart-o"></i>清洁生产评价</a>

                </ul>
            </li>

            <li id="entity_sensor"><a href="#"><i
                    class="fa fa-fw fa-file"></i>设备管理</a></li>

            <li id="shuixinxi"><a href="#"><i class="fa fa-qrcode"></i>水信息管理<span
                    class="fa arrow"></span></a>
                <ul class="nav nav-second-level">
                    <li><a id="entity_water" href="#"><i
                            class="fa fa-bar-chart-o"></i>数据采集</a></li>
                    <li><a id="water_visual" href="#"><i
                            class="fa fa-bar-chart-o"></i>查询数据</a></li>
                </ul>
            </li>

            <!--毕设-->
            <li id="flowchart"><a href="#"><i class="fa fa-bar-chart-o"></i>工艺流程<span
                    class="fa arrow"></span></a>
                <ul class="nav nav-second-level">
                    <li><a id="craft_gallery" href="#"><i
                            class="fa fa-bar-chart-o"></i>工艺图库</a></li>
                    <li><a id="technological_process" href="#"><i
                            class="fa fa-bar-chart-o"></i>工艺流程</a></li>
                </ul>
            </li>
            <!--毕设-->

            <li id="warning-"><a href="#"><i class="fa fa-qrcode"></i>预警<span
                    class="fa arrow"></span></a>
                <ul class="nav nav-second-level">
                    <li><a id="warnning_rule" href="#"><i
                            class="fa fa-bar-chart-o"></i>预警规则</a></li>
                    <li><a id="warnning_record" href="#"><i
                            class="fa fa-bar-chart-o"></i>预警记录</a></li>
                </ul>
            </li>
            <li id="water_balance"><a id="label_water_bala" href="#"><i class="fa fa-bar-chart-o"></i>水平衡测试</a>
            </li>
            <!--li id="water_balance_normal" style="display: none;"><a id="label_water_bala_normal" href="#" ><i class="fa fa-bar-chart-o"></i>水平衡测试</a>
            </li-->


            <!--
            <li><a href="#"><i class="fa fa-qrcode"></i>水平衡<span
                    class="fa arrow"></span></a>
                <ul class="nav nav-second-level">
                    <li><a id="entity_eva_wsrc_info" href="#"><i
                            class="fa fa-bar-chart-o"></i>企业取水水源表</a></li>
                    <li><a id="entity_eva_year_wuse_info" href="#"><i
                            class="fa fa-bar-chart-o"></i>企业年用水表</a></li>
                    <li><a id="entity_evb_produce_info" href="#"><i
                            class="fa fa-bar-chart-o"></i>企业生产情况统计表</a></li>
                    <li><a id="measuring_water_info" href="#"><i
                            class="fa fa-bar-chart-o"></i>全厂计量水表配备</a></li>
                    <li><a id="entity_eva_unit_wbal_test" href="#"><i
                            class="fa fa-bar-chart-o"></i>用水单元水平衡测试表</a></li>
                    <li><a id="entity_eva_wbal_test" href="#"><i
                            class="fa fa-bar-chart-o"></i>企业水平衡测试统计表</a></li>
                    <li><a id="label_eva_cmp_water_anl" href="#"><i
                            class="fa fa-bar-chart-o"></i>企业用水分析表</a></li>
                    <li><a id="label_eva_wbal_chart" href="#"><i
                            class="fa fa-bar-chart-o"></i>水平衡图</a></li>

                </ul>
            </li>
            -->


            <li><a id="entity_waste_water" href="#"><i class="fa fa-bar-chart-o"></i>废水排放评价</a></li>
            <li><a id="clean" href="#"><i class="fa fa-bar-chart-o"></i>清洁生产</a></li>
            <li><a id="classified_standard" href="#"><i class="fa fa-bar-chart-o"></i>取水定额</a></li>
            <li><a id="Water_saving" href="#"><i
                    class="fa fa-fw fa-file"></i>节水型企业评价</a></li>
            <!--li id="users" style="display: none;"><a id="user_control" href="#"><i
                    class="fa fa-fw fa-file"></i>用户管理</a></li>
            <li><a id="login_control" href="#"><i class="fa fa-fw fa-file"></i>登录日志管理</a></li-->
            <!--            <li><a id="companys" href="#"><i class="fa fa-bar-chart-o"></i>公司管理</a></li>-->
            <li id="li_users"><a href="#"><i class="fa fa-qrcode"></i>权限管理<span
                    class="fa arrow"></span></a>
                <ul class="nav nav-second-level">
                    <li><a id="companys" href="#"><i
                            class="fa fa-bar-chart-o"></i>企业管理</a></li>
                    <!--                    <li><a id="users" href="#"><i-->
                    <!--                            class="fa fa-bar-chart-o"></i>用户管理</a></li>-->
                    <!--                    <li><a id="roles" href="#"><i-->
                    <!--                            class="fa fa-bar-chart-o"></i>角色管理</a></li>-->
                    <li><a id="login_control" href="#"><i
                            class="fa fa-bar-chart-o"></i>登录日志</a></li>
                </ul>
            </li>
        </ul>
    </div>
</div>

<!--script src="pages/js/permission.js"></script-->
<script>
    var data;
    var companyId;
    var user_Role = ''


    $('#main-menu').metisMenu();
    // 隐藏下拉菜单
    $(window).bind("load resize", function () {
        if ($(this).width() < 768) {
            $('div.sidebar-collapse').addClass('collapse')
        } else {
            $('div.sidebar-collapse').removeClass('collapse')
        }
    });


    // 向左隐藏菜单
    $("#sideNav").click(function () {
        if ($(this).hasClass('closed')) {
            $('.navbar-side').animate({
                left: '0px'
            });
            $(this).removeClass('closed');
            $('#page-wrapper').animate({
                'margin-left': '260px'
            });
        } else {
            $(this).addClass('closed');
            $('.navbar-side').animate({
                left: '-260px'
            });
            $('#page-wrapper').animate({
                'margin-left': '0px'
            });
        }
    });

    $(function () {
        hasPermission()
        $.ajax({
            type: 'get',
            url: '/sideMenu/sideMenu',
            async: false,
            success: function (data) {
                companyId = data["companyid"]
                user_Role = data['role']
                //拼接下拉框
                if (data["role"] == "管理员") {
                    document.getElementById("yuan").style.display = "";
                    document.getElementById("users").style.display = "";
                    document.getElementById('water_balance').style.display = "";
                } else if (data["role"] == "普通用户") {
                    document.getElementById("water_balance_normal").style.display = "";
                } else if (data["role"] == "-1") {
                    window.alert("请先登录");
                    window.location.href = "/login.html";
                }
            }
        });
    })
    function queryPermission(authName, info, id) {
        $.ajax({
            type: 'get',
            url: '/authority/query-permission',
            async: false,
            data: {
                'authName': authName,
                'info': info,
            },
            success: function (data) {
                if (data.result >= 1) {
                    $("#" + id).show()
                } else {
                    $("#" + id).hide()
                }
            }
        });
    }

    function hasPermission() {
        queryPermission('元数据', '视图', 'yuan')
        queryPermission('元数据/设备基本信息', '视图', 'meta_sensor')
        queryPermission('元数据/水平衡测试', '视图', 'shuipingheng')
        queryPermission('元数据/水平衡测试/企业取水水源情况', '视图', 'meta_eva_wsrc_info')
        queryPermission('元数据/水平衡测试/企业年用水情况', '视图', 'meta_eva_year_wuse_info')
        queryPermission('元数据/水平衡测试/用水单元水平衡测试', '视图', 'meta_eva_unit_wbal_test')
        queryPermission('元数据/水平衡测试/企业水平衡测试统计表', '视图', 'meta_eva_wbal_test')
        queryPermission('元数据/废水排放评价', '视图', 'meta_discharge')
        queryPermission('元数据/节水型企业评价', '视图', 'meta_standard')
        queryPermission('元数据/取水定额评估', '视图', 'meta_QSDE')
        queryPermission('元数据/清洁生产评价', '视图', 'meta_clean_product')
        queryPermission('水信息管理/数据采集', '视图', 'entity_water')
        queryPermission('水信息管理/查询数据', '视图', 'water_visual')
        queryPermission('预警', '视图', 'warning-')
        queryPermission('设备管理', '视图', 'entity_sensor')
        queryPermission('水信息管理', '视图', 'shuixinxi')
        queryPermission('工艺流程', '视图', 'flowchart')
        queryPermission('水平衡测试', '视图', 'water_balance')
        queryPermission('废水排放评价', '视图', 'entity_waste_water')
        queryPermission('清洁生产', '视图', 'clean')
        queryPermission('取水定额', '视图', 'classified_standard')
        queryPermission('节水型企业评价', '视图', 'Water_saving')
        queryPermission('权限管理', '视图', 'li_users')
        queryPermission('权限管理/企业管理', '视图', 'companys')
        // queryPermission('权限管理/用户管理', '视图', 'users')
        // queryPermission('权限管理/角色管理', '视图', 'roles')
        queryPermission('权限管理/登录日志', '视图', 'login_control')
        queryPermission('预警/预警规则', '视图', 'warnning_rule')
        queryPermission('预警/预警记录', '视图', 'warnning_record')
    }

    $("#flowchart").show();

</script>

<script>
    var page_name;
    var page_url;
    var authName;
    var info;
    var user_company_id;
    $("#meta_sensor").click(function () {
        //$('#page-wrapper').load('pages/meta_sensor.html');
        page_name = '设备元数据管理'
        page_url = "pages/meta_sensor.html"
        authName = "元数据/设备基本信息"
        $('#page-wrapper').load('pages/technological_process.html');
    });
    $("#meta_standard").click(function () {
        $('#page-wrapper').load('pages/meta_standard.html');
    });
    $("#meta_QSDE").click(function () {
        $('#page-wrapper').load('pages/meta_QSDE.html');
    });
    $("#meta_discharge").click(function () {
        $('#page-wrapper').load('pages/meta_discharge.html');
    });
    $("#meta_standard_require").click(function () {
        $('#page-wrapper').load('pages/meta_standard_require.html');
    });
    $("#entity_sensor").click(function () {
        //$('#page-wrapper').load('pages/entity_sensor.html');
        page_name = "设备管理"
        page_url = "pages/entity_sensor.html"
        authName = "设备管理"
        $('#page-wrapper').load('pages/technological_process.html');
    });
    $("#meta_water").click(function () {
        $('#page-wrapper').load('pages/meta_water.html');
    });
    $("#entity_water").click(function () {
        //$('#page-wrapper').load('pages/entity_water.html');
        page_name = "数据采集"
        page_url = "pages/entity_water.html"
        authName = "水信息管理/数据采集"
        $('#page-wrapper').load('pages/technological_process.html');
    });
    $("#water_visual").click(function () {
        //$('#page-wrapper').load('pages/water_visual.html');
        page_name = "查询数据"
        page_url = "pages/water_visual.html"
        authName = "水信息管理/查询数据"
        $('#page-wrapper').load('pages/technological_process.html');
    });

    $("#craft_gallery").click(function () {
        page_name = '工艺图库'
        page_url = "pages/craft_gallery.html"
        authName = "工艺流程/工艺图库"
        $('#page-wrapper').load('pages/technological_process.html');
    });
    $("#technological_process").click(function () {
        page_name = '工艺流程管理'
        page_url = "pages/flowchart_table.html"
        authName = "工艺流程/工艺流程管理"
        $('#page-wrapper').load('pages/technological_process.html');
    });

    $("#label_water_bala").click(function () {
        $('#page-wrapper').load('pages/label_water_bala.html');
    });
    $("#label_water_bala_normal").click(function () {
        label_water_bala_companyId = companyId;
        $('#page-wrapper').load('pages/label_entity_water_bala.html');
    });

    $("#meta_eva_wsrc_info").click(function () {
        $('#page-wrapper').load('pages/meta_eva_wsrc_info.html');
    });
    $("#entity_eva_wsrc_info").click(function () {
        $('#page-wrapper').load('pages/label_eva_wsrc_info.html');
    });
    $("#meta_eva_year_wuse_info").click(function () {
        $('#page-wrapper').load('pages/meta_eva_year_wuse_info.html');
    });
    $("#entity_eva_year_wuse_info").click(function () {
        $('#page-wrapper').load('pages/entity_eva_year_wuse_info.html');
    });
    $("#measuring_water_info").click(function () {
        $('#page-wrapper').load('pages/entity_eva_water_sensor_info.html');
    });
    $("#entity_evb_produce_info").click(function () {
        $('#page-wrapper').load('pages/label_evb_produce_info.html');
    });
    $("#meta_eva_unit_wbal_test").click(function () {
        $('#page-wrapper').load('pages/meta_eva_unit_wbal_test.html');
    });
    $("#entity_eva_unit_wbal_test").click(function () {
        $('#page-wrapper').load('pages/entity_eva_unit_wbal_test.html');
    });
    $("#label_eva_cmp_water_anl").click(function () {
        $('#page-wrapper').load('pages/label_eva_cmp_water_anl.html');
    });
    $("#warnning_rule").click(function () {
        //$('#page-wrapper').load('pages/warnning_rule.html');
        page_name = "预警规则"
        page_url = "pages/warnning_rule.html"
        authName = "预警/预警规则"
        $('#page-wrapper').load('pages/technological_process.html');
    });
    $("#warnning_record").click(function () {
        //$('#page-wrapper').load('pages/warnning_record.html');
        page_name = "预警记录"
        page_url = "pages/warnning_record.html"
        authName = "预警/预警记录"
        $('#page-wrapper').load('pages/technological_process.html');
    });
    $("#meta_eva_wbal_test").click(function () {
        $('#page-wrapper').load('pages/meta_eva_wbal_test.html');
    });
    $("#entity_eva_wbal_test").click(function () {
        $('#page-wrapper').load('pages/label_eva_wbal_test.html');
    });
    $("#label_eva_wbal_chart").click(function () {
        $('#page-wrapper').load('pages/label_eva_wbal_chart.html');
    });
    $("#meta_waste_water").click(function () {
        $('#page-wrapper').load('pages/meta_eva_waste_water.html');
    });
    $("#classified_standard").click(function () {
        $('#page-wrapper').load('pages/entity_classified_standard.html');
    });
    $("#water_account").click(function () {
        $('#page-wrapper').load('pages/entity_water_account.html');
    });
    $("#Water_saving").click(function () {
        $('#page-wrapper').load('pages/label_water_saving.html');
    });
    $("#entity_waste_water").click(function () {
        $('#page-wrapper').load('pages/entity_eva_waste_water_main.html');
    });

    $("#clean").click(function () {
        $('#page-wrapper').load('pages/new_clean_product.html');
    });
    $("#companys").click(function () {
        page_name = "企业管理"
        $('#page-wrapper').load('pages/companys.html');
    });
    $("#users").click(function () {
        //$('#li_users').hide();
        $('#page-wrapper').load('pages/entity_user_control.html');
    });
    $("#roles").click(function () {
        page_name = "角色管理"
        $('#page-wrapper').load('pages/roles.html');
    });
    $("#login_control").click(function () {
        $('#page-wrapper').load('pages/entity_login_control.html');
    });
    $("#meta_clean_product").click(function () {
        $('#page-wrapper').load('pages/meta_clean_product.html');
    });


</script>